#!/usr/bin/python
# -*- coding: UTF-8 -*-

from time import sleep
from MiniBotControlLib import MiniBotControlLib
from BwSensorLib import BwSensorLib

# 声明控制库对象
mlib = MiniBotControlLib("udp")
# 声明传感器库对象
sensorlib = BwSensorLib(mlib)
# 连接机器人
ip = "10.10.100.254"
mlib.Connect(ip, 8899)

# 点亮RBG灯
def main():
    # 点亮RGB灯
    # 红色：[255, 0, 0]，绿色：[0, 255, 0]，蓝色[0, 0, 255]， 熄灭：[0, 0, 0]
    rgbValue = [[255, 0, 0], [0, 255, 0], [0, 0, 255], [0, 0, 0]]
    # RBG灯从红色->绿色->蓝色->熄灭循环2次
    for i in range(2):
        for a in range(4):
            sensorLib.setRGBLightSensor(rgbValue[a])
            sleep(2)

if __name__ == "__main__":
    try:
        main()
    except KeyboardInterrupt:
        print(" Program closed! ")
    pass
